﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="pol_isikud2_paring", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(PolIsikud2Paring))]
    public class PolIsikud2ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IPolIsikud2Paring clazz;
        
        public PolIsikud2ParingSerializer(IPolIsikud2Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Id!=null) {
                Writer.WriteStartElement("id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Id))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Perenimi!=null) {
                Writer.WriteStartElement("perenimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perenimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Synniaeg!=null) {
                Writer.WriteStartElement("synniaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Synniaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Isikukood!=null) {
                Writer.WriteStartElement("isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.JuhiloaNumber!=null) {
                Writer.WriteStartElement("juhiloa_number");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JuhiloaNumber))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kuupaev!=null) {
                Writer.WriteStartElement("kuupaev");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kuupaev))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.FotoAllkiri!=null) {
                Writer.WriteStartElement("foto_allkiri");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.FotoAllkiri))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Max!=null) {
                Writer.WriteStartElement("max");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Max))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>id");
                }
                clazz.Id = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("id")).Value;
            }
            if (Reader.LocalName=="eesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>eesnimi");
                }
                clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            }
            if (Reader.LocalName=="perenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>perenimi");
                }
                clazz.Perenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perenimi")).Value;
            }
            if (Reader.LocalName=="synniaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>synniaeg");
                }
                clazz.Synniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synniaeg")).Value;
            }
            if (Reader.LocalName=="isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            }
            if (Reader.LocalName=="juhiloa_number") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>juhiloa_number");
                }
                clazz.JuhiloaNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("juhiloa_number")).Value;
            }
            if (Reader.LocalName=="kuupaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>kuupaev");
                }
                clazz.Kuupaev = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kuupaev")).Value;
            }
            if (Reader.LocalName=="foto_allkiri") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>foto_allkiri");
                }
                clazz.FotoAllkiri = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("foto_allkiri")).Value;
            }
            if (Reader.LocalName=="max") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_isikud2_paring>max");
                }
                clazz.Max = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("max")).Value;
            }
        }
    }
}
